package ee.falcon.controller;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import ee.falcon.gui.frame.NewOrEditProfileFrame;
import ee.falcon.gui.frame.ProfilesFrame;

public class ExitAndCloseButtonListener extends WindowAdapter implements ActionListener
{
	private NewOrEditProfileFrame newOrEditProfileFrame; 
	private ProfilesFrame profileFrame; 
	
	public ExitAndCloseButtonListener(NewOrEditProfileFrame newOrEditProfile, ProfilesFrame profileFrame)
	{
		this.newOrEditProfileFrame = newOrEditProfile; 
		this.profileFrame = profileFrame; 
	}
	
	@Override
    public void windowClosing(WindowEvent windowClosingArgument) 
    {
		closeNewOrEditProfileFrame(); 
    }

	@Override
	public void actionPerformed(ActionEvent windowClosingEvent)
	{
		closeNewOrEditProfileFrame(); 	
	}
	
	public void closeNewOrEditProfileFrame()
	{
		profileFrame.setEnabled(true); 
		newOrEditProfileFrame.setVisible(false); 
		newOrEditProfileFrame.dispose(); 
	}
	
	//[START]GETTERS AND SETTERS
	public ProfilesFrame getProfilesFrame()
	{
		return this.profileFrame; 
	}
	
	public NewOrEditProfileFrame getNewOrEditProfileFrame()
	{
		return this.newOrEditProfileFrame; 
	}
	//[END]GETTERS AND SETTERS
}
